﻿using System.Collections.Generic;

//目前复杂的背包搜索还需要考虑一下情况
//1. 目前搜索条件不支持 或者
//2. 搜索结构可能会发生改变
//3. 道具的总属性 可能放入其他结构体中
//4. ItemFilterFun考虑以多态形式展现

namespace UFrame
{
    public sealed class ItemMa : Singleton<ItemMa>
    {
        private List<ItemBase> mItemList = new List<ItemBase>();
        private SearchCollection<ItemBase> mSC = new SearchCollection<ItemBase>();

        private ItemMa()
        {

        }

        public void TestInit()
        {
            mItemList.Add(new ItemBase()
            {
                Name = "幽梦之刃",
                ConfigId = 101,
                BigType = 1,
                SubType = 1,
                Bind = true,
                TimeType = TimelimitEnum.None
            });
            mItemList.Add(new ItemBase()
            {
                Name = "幽梦之刃",
                ConfigId = 101,
                BigType = 1,
                SubType = 1,
                Bind = false,
                TimeType = TimelimitEnum.None
            });
            mItemList.Add(new ItemBase()
            {
                Name = "幽梦之刃",
                ConfigId = 101,
                BigType = 1,
                SubType = 1,
                Bind = true,
                TimeType = TimelimitEnum.None
            });
            mItemList.Add(new ItemBase()
            {
                Name = "无尽之刃",
                ConfigId = 102,
                BigType = 1,
                SubType = 1,
                Bind = true,
                TimeType = TimelimitEnum.PastDue
            });

            mSC.Init();
            mSC.AddFilter(EItemSearch.ConfigId, new ItemExpConfigId());
            mSC.AddFilter(EItemSearch.Bind, new ItemExpBind());
            mSC.AddFilter(EItemSearch.IsEquip, new ItemExpIsEquip());
            mSC.AddFilter(EItemSearch.IsMaterial, new ItemExpIsMaterial());
            mSC.AddFilter(EItemSearch.IsSpecial, new ItemExpIsSpecial());
            mSC.AddFilter(EItemSearch.TimeType, new ItemExpTimeType());
        }

        public List<ItemBase> Get(Dictionary<int, object> condition)
        {
            return mSC.Get(condition, mItemList);
        }

    }


    #region Item的数据
    public class ItemBase
    {
        public string Name;
        public int Pos;
        public int ConfigId;
        public bool Bind;
        public int BigType;
        public int SubType;
        public TimelimitEnum TimeType;
    }

    public enum TimelimitEnum
    {
        None = -1,
        PastDue = 0,
        NoPastDue = 1
    }

    public enum ItemType
    {
        //(0-装备，1-消耗品，2材料，3宝箱)

        Equip = 0,
        Consume = 1,
        Material = 2,
        Task = 3,
        Gem = 4,
        SkillBook = 5,
        SkillGoods = 6,
        NumberGoods = 7,
        Chest = 8,
        TimeLimit = 9,
        Currency = 999,
    }

    public class EItemSearch
    {
        public const int ConfigId = 1;
        public const int Bind = 2;
        public const int TimeType = 3;
        public const int IsEquip = 4;
        public const int IsMaterial = 5;
        public const int IsSpecial = 6;
    }

    #endregion
}